package com.ftg.youx.controller;

import com.alibaba.fastjson2.JSON;
import com.ftg.youx.entity.SysEmp;
import com.ftg.youx.tools.R;
import jakarta.annotation.Resource;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.core.RabbitMessagingTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 发送端
 *
 * @author 布衣
 */
@RestController
public class SendMsgController {

    @Resource
    AmqpTemplate amqp;

    @PostMapping("/rev")
    public R revMessage(@RequestBody  @Validated SysEmp sysEmp){
        amqp.convertAndSend("queue01", JSON.toJSONString(sysEmp));
        return R.ok("mq添加成功",sysEmp);
    }

}
